package com.hua.store.web.servlet;

import com.hua.store.domin.Product;
import com.hua.store.service.ProductService;
import com.hua.store.service.impl.ProductServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.SQLException;
import java.util.List;

public class IndexServlet extends BaseServlet {
    @Override
    public String execute(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException, SQLException {
        //CategoryService service = new CategoryServiceImpl();
        //List<Category> list = service.getAllCats();
        //System.out.println("com.hua.store.web.servlet.IndexServlet");
        //req.setAttribute("allCats", list);

        ProductService service = new ProductServiceImpl();
        List<Product> listNew = service.getNewPro();
        List<Product> listHot = service.getHotPro();

        req.setAttribute("news", listNew);
        req.setAttribute("hots", listHot);

        return "/jsp/index.jsp";
    }
}
